package com.itboye.boyeshoping.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.boyeshoping.R;

/**
 * Created by Administrator on 2018/6/29 0029.
 */

public class GoodsListAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater inflater;
    public GoodsListAdapter(Context context){
        this.context=context;
        this.inflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return 4;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
       MyViewHolder holder;
        if (view==null){
            holder=new MyViewHolder();
            view=inflater.inflate(R.layout.item_goodslist,null,false);

            holder.goodname= (TextView) view.findViewById(R.id.goodname);
            holder.goodIv= (ImageView) view.findViewById(R.id.goodIv);

            holder.newPrice= (TextView) view.findViewById(R.id.newPrice);
            holder.oldPrice= (TextView) view.findViewById(R.id.oldPrice);
            holder.onePay= (TextView) view.findViewById(R.id.onePay);
            holder.sellNums= (TextView) view.findViewById(R.id.sellNums);
            holder.voucherTv= (TextView) view.findViewById(R.id.voucherTv);
            view.setTag(holder);
        }else {
            holder= (MyViewHolder) view.getTag();
        }

        //        2、textView设置中划线
//
//        textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中划线
//        setFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG); // 设置中划线并加清晰
        holder.oldPrice.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG); //中划线

        return view;
    }

    class MyViewHolder{
        ImageView goodIv;
        TextView goodname,newPrice,oldPrice,onePay,sellNums,voucherTv;

    }
}
